package com.bos.util;

import java.net.URLEncoder;


public class GetWeiXinCode {
    //https://open.weixin.qq.com/connect/oauth2/authorize?appid=wx39b1bb2c2b663946&redirect_uri=bos.shgae.cn&response_type=code&scope=SCOPE&state=STATE#wechat_redirect
    public static String GetCodeRequest = "https://open.weixin.qq.com/connect/oauth2/authorize?appid=APPID&redirect_uri=REDIRECT_URI&response_type=code&scope=SCOPE&state=STATE#wechat_redirect";

    public static String getCodeRequest() {
        String result = null;
        GetCodeRequest = GetCodeRequest.replace("APPID", urlEnodeUTF8(WeiXinParamesUtil.APPID));
        GetCodeRequest = GetCodeRequest.replace("REDIRECT_URI", urlEnodeUTF8(WeiXinParamesUtil.REDIRECT_URI));
        GetCodeRequest = GetCodeRequest.replace("SCOPE", WeiXinParamesUtil.SCOPE);
        GetCodeRequest = GetCodeRequest.replace("STATE", "123");
        result = GetCodeRequest;
        return result;
    }

    public static String urlEnodeUTF8(String str) {
        String result = str;
        try {
            result = URLEncoder.encode(str, "UTF-8");
            System.out.println(result);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return result;
    }


}
